package com.summer.data.jql.builder;

import com.summer.data.Jsql;
import com.summer.data.dialect.Dialect;
import com.summer.data.jql.Context;
import com.summer.data.jql.JsqlAble;
import com.summer.data.jql.compose.FilterPack;

/**
 * @author 345480567@qq.com
 */

public class WhereBuilder extends FilterPack implements JsqlAble {

    Context ctx;

    public WhereBuilder(Context ctx) {
        this.ctx = ctx;
    }

    @Override
    public Jsql buildJsql(Dialect dialect) {
        if (size() > 0) {
            return Jsql.format(" WHERE %s %s", toFilterJsql(ctx, dialect), System.lineSeparator());
        } else {
            return new Jsql();
        }
    }

}

